* Date: May 19th, 2024

est clear

* Set user-defined paths (prompt users to set input and output directories)
local inputPath = `"`c(pwd)'"'
local outputPath = `"`c(pwd)'"'

* Load dataset (update filename as needed)
local dataFile = "`inputPath'/local_ptojection.dta"
use "`dataFile'", clear

* Change to the output directory
cd "`outputPath'"

* Set panel data structure (replace identifiers if needed)
xtset iso_num year

* Generate GDP growth
qui gen GDP_growth = (rgdppc - L.rgdppc) / L.rgdppc * 100

* Generate finance sentiment first difference and level
qui gen Finance_sentiment_fd = (all_stdscore - L.all_stdscore) * 100
qui gen Finance_sentiment = all_stdscore

* Keep only relevant variables and arrange them in a specific order
keep iso_num year GDP_growth Finance_sentiment_fd
order iso_num year GDP_growth Finance_sentiment_fd

* Save the processed data to output path (update filename as needed)
local outputDataFile = "`outputPath'/lp_allstd.dta"
save "`outputDataFile'", replace
